package com.newbingo.entity;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import com.newbingo.domain.common.Identity;

@Entity
public class Perview implements Serializable {
	@Identity
	private Integer perviewId;
	private String perviewName;
	private String url;
	private Perview parentPerview;
	private Set<Perview> childPerviews;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public Integer getPerviewId() {
		return perviewId;
	}
	public void setPerviewId(Integer perviewId) {
		this.perviewId = perviewId;
	}
	public String getPerviewName() {
		return perviewName;
	}
	public void setPerviewName(String perviewName) {
		this.perviewName = perviewName;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	
	@ManyToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER,targetEntity=Perview.class)
	@JoinColumn(name="parentperview_id")
	public Perview getParentPerview() {
		return parentPerview;
	}
	public void setParentPerview(Perview parentPerview) {
		this.parentPerview = parentPerview;
	}
	
	@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY,mappedBy="parentPerview")
	public Set<Perview> getChildPerviews() {
		return childPerviews;
	}
	public void setChildPerviews(Set<Perview> childPerviews) {
		this.childPerviews = childPerviews;
	}
	
}
